home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / benchmarks / itc / sas / a.out.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-30  |  7.3 KB  |  224 lines

  1. /*  $Header: a.out.h,v 2.2 88/09/28 00:04:58 hilfingr Exp $ */
  2.  
  3. /* Format of a.out files, as seen by as, ld, and the kernel.  The kernel's
  4.  * knowledge is restricted to the contents of sys/exec.h. 
  5.  */
  6.  
  7. #include "sys/exec.h"
  8.  
  9. /*
  10.  * memory management parameters
  11.  */
  12.  
  13. #define PAGSIZ        0x1000
  14.  
  15. /*
  16.  * returns 1 if an object file type is invalid, i.e., if the other macros
  17.  * defined below will not yield the correct offsets.  Note that a file may
  18.  * have N_BADMAG(x) = 0 and may be fully linked, but still may not be
  19.  * executable.
  20.  */
  21.  
  22. #define    N_BADMAG(x) \
  23.     ((x).a_magic!=ZMAGIC && (x).a_magic!=OMAGIC)
  24.  
  25. /*
  26.  * relocation parameters. These are architecture-dependent
  27.  * and can be deduced from the machine type.  They are used
  28.  * to calculate offsets of segments within the object file;
  29.  * See N_TXTOFF(x), etc. below.
  30.  */
  31.  
  32. #define N_PAGSIZ(x) PAGSIZ
  33.  
  34. /*
  35.  * offsets of various sections of an object file.
  36.  */
  37.  
  38.  
  39. #define    N_TXTOFF(x) \
  40.     ((x).a_magic == ZMAGIC ? 0 : sizeof (struct exec))
  41.  
  42. #define N_DATAOFF(x) \
  43.         (N_TXTOFF(x)+(x).a_text)
  44.  
  45. #define N_SDATAOFF(x) \
  46.         (N_DATAOFF(x)+(x).a_data)
  47.  
  48. #define N_RELOCOFF(x) \
  49.         (N_SDATAOFF(x)+(x).a_sdata)
  50.  
  51. #define N_EXPOFF(x) \
  52.     (N_RELOCOFF(x)+(x).a_rsize)
  53.  
  54. #define    N_SYMOFF(x) \
  55.     /* symbol table */ \
  56.     (N_EXPOFF(x)+(x).a_expsize)
  57.  
  58. #define    N_STROFF(x) \
  59.     /* string table */ \
  60.     (N_SYMOFF(x) + (x).a_syms)
  61.  
  62. /*
  63.  * Macros which take exec structures as arguments and tell where the
  64.  * various pieces will be loaded.
  65.  */
  66.  
  67. #define N_TXTADDR(x) \
  68.     ((x).a_magic == ZMAGIC ? 0x40000000 : 0)
  69.  
  70. #define N_DEFENT(x) \
  71.     (N_TXTADDR(x) + ((x).a_magic == ZMAGIC ? sizeof(struct exec) : 0))
  72.  
  73. #define N_DATADDR(x) \
  74.     ((x).a_magic == ZMAGIC ? 0xc0000000 : N_TXTADDR(x) + (x).a_text)
  75.  
  76. #define N_BSSADDR(x)  (N_DATADDR(x)+(x).a_data)
  77.  
  78. #define N_SDATADDR(x) 0x80000000
  79.  
  80. #define N_SBSSADDR(x) (N_SDATADDR(x) + (x).a_sdata)
  81.  
  82.  
  83. /*
  84.  * Format of a relocation datum.
  85.  */
  86.  
  87. struct relocation_info {
  88. unsigned int r_address:27,  /* offset in segment of quantity to be */
  89.                             /* relocated. */
  90.              r_segment:4,   /* segment to be used as the base */
  91.                             /* for r_address. */
  92.              r_dummy:1;     /* padding. */
  93. unsigned int r_expr:24,        /* offset in expression data if r_reltype 
  94.                  * is RP_REXP; 
  95.                  * symbol ordinal, if r_reltype is RP_RSYM;
  96.                  * or one of the values N_TEXT, N_DATA, N_SDATA,
  97.                  * N_BSS, or N_SBSS, if r_reltype is RP_RSEG.
  98.                  */
  99.              r_word:1,      /* 1 iff location requires word address */
  100.              r_reltype:2,   /* operation to perform */
  101.              r_length:3,    /* bits to be modified */
  102.              r_extra:2;     /* Must be 0. */
  103. };
  104.  
  105. /* Values for r_reltype */
  106. #define RP_RSEG  0      /* add relocation increment of segment r_expr. */
  107. #define RP_RSYM  1      /* add value of symbol r_expr. */
  108. #define RP_REXP  2      /* set to expression indexed by r_expr. */
  109.  
  110. /* Values for r_length */
  111. /* Note: the address of the modified data must be a multiple of 4 */
  112. /* except when r_length is RP_LOW16, in which case is must be even, */
  113. /* or when r_length is RP_LOW8, when there is no restriction. */
  114. #define RP_LOW8  0      /* low-order 8 bits */
  115. #define RP_LOW9  1      /* low-order 9 bits */
  116. #define RP_LOW14 2      /* low-order 14 bits */
  117. #define RP_LOW16 3      /* low-order 16 bits */
  118. #define RP_SCONS 4      /* store constant (bits 0-8 and 20-24) */
  119. #define RP_LOW28 5      /* low-order 28 bits */
  120. #define RP_32    6      /* full long word */
  121.  
  122. /* Values for r_segment */
  123. #define RP_TEXT0   0    /* Text segment */
  124. #define RP_DATA0   1    /* Private data segment */
  125. #define RP_SDATA0  2    /* Shared data segment */
  126. #define RP_SYMBOLS 3    /* Symbol table */
  127. #define RP_BSS       4    /* Unitialized private data segment */
  128. #define RP_SBSS    5    /* Uninitialized shared data segment */
  129. #define RP_SEG0    6    /* Symbol 0. */
  130. #define RP_SEGLAST 15   /* Last available segment number. */
  131.  
  132. /*
  133.  * Definitions of expressions.
  134.  *
  135.  * Expressions are stored in prefix form as a sequence of reloc_exprs.  The
  136.  * operators are described in the #defines below.  
  137.  */
  138.  
  139. union reloc_expr {
  140.     unsigned int     re_value;    /* Unsigned integer value, following an
  141.                      * EO_INT, EO_SYM, EO_TEXT, EO_DATA, or
  142.                      * EO_BSS syllable. */
  143.     struct {
  144.     unsigned int    re_op:8,    /* Operator (see EO_xxx below). */
  145.                         re_arg:24;    /* Argument modifying EO_SYM. */
  146.     } re_syl;
  147. };
  148.     
  149.     /* Constructor */
  150. #define EO_SET_SYL2(x,op,arg) { (x).re_syl.re_op = (op); (x).re_syl.re_arg =(arg); }
  151. #define EO_SET_SYL(x,op) { (x).re_syl.re_op = (op); }
  152.  
  153. /* Values of re_op.  In the following, x is the re_value of the */
  154. /* following syllable. */
  155. #define EO_INT   0      /* x */
  156. #define EO_SYM   1      /* x + symbol at index re_arg in symbol table. */
  157. #define EO_TEXT  4      /* x + base of text segment. */
  158. #define EO_DATA  5      /* x + base of private data segment. */
  159. #define EO_BSS   6      /* x + base of uninitialized data. */
  160. #define EO_SDATA 7      /* x + base of shared data segment. */
  161. #define EO_SBSS  8      /* x + base of shared uninitialized data. */
  162.  
  163. /* Unary operators: x is value of the following expression. */
  164. #define EO_MINUS 9       /* -x */
  165. #define EO_COMP  10      /* !x */
  166.  
  167. /* Binary operators: x and y are the values of the following two */
  168. /* expressions. */
  169. #define EO_PLUS 11      /* x+y */
  170. #define EO_MULT 12      /* x*y */
  171. #define EO_DIV  13      /* x/y (integer division) */
  172. #define EO_SLL  14      /* logical left shift. */
  173. #define EO_SRL  15      /* logical right shift */
  174. #define EO_AND  16      /* logical bitwise and */
  175. #define EO_OR   17      /* logical bitwise or */
  176. #define EO_XOR  18      /* logical bitwise exclusive or */
  177. #define EO_SUB  19      /* x-y */
  178.  
  179. /*
  180.  * Format of a symbol table entry
  181.  */
  182. struct  nlist {
  183.     union {
  184.             char    *n_name;        /* convenience only --  */
  185.                                     /* unused in object file */
  186.             long    n_strx;         /* index into string table */
  187.     } n_un;
  188.     unsigned char   n_type;         /* type flag, see below  */
  189.     char    n_other;                /* Must be 0 */
  190.     short   n_desc;                 /* debugging data, q.v. */
  191.     unsigned long   n_value;        /* value (or offset) of symbol,
  192.                                      * length of common area. */
  193. };
  194.  
  195.  
  196. /* Values for n_type field */
  197. #define N_UNDF  0x0             /* undefined */
  198. #define N_ABS   0x2             /* absolute */
  199. #define N_TEXT  0x4             /* text-relative */
  200. #define N_DATA  0x6             /* data-relative */
  201. #define N_BSS   0x8             /* bss-relative */
  202. #define N_SDATA 0xa             /* shared data-relative */
  203. #define N_SBSS  0xe             /* shared bss-relative */
  204. #define N_EXPR  0x10            /* value to be filled in by load-time */
  205.                                 /* expression */
  206. #define N_COMM  0x12            /* common region: n_value gives length */
  207. #define N_SCOMM 0x14        /* shared common region: n_value gives
  208.                  * length */
  209.  
  210. #define N_EXT   01              /* external bit, or'ed in to indicate */
  211.                                 /* imported or exported definitions */
  212. #define N_TYPE  0x1e            /* mask for all the type bits */
  213.  
  214. /*
  215.  * Dbx entries have some of the N_STAB bits set.
  216.  * These are given in <stab.h>
  217.  */
  218. #define    N_STAB    0xe0        /* if any of these bits set, a dbx symbol */
  219.  
  220. /*
  221.  * Format for namelist values.
  222.  */
  223. #define    N_FORMAT    "%08x"
  224.